<?php

use Faker\Factory as Faker;
use App\Models\Cooperation;
use App\Repositories\CooperationRepository;

trait MakeCooperationTrait
{
    /**
     * Create fake instance of Cooperation and save it in database
     *
     * @param array $cooperationFields
     * @return Cooperation
     */
    public function makeCooperation($cooperationFields = [])
    {
        /** @var CooperationRepository $cooperationRepo */
        $cooperationRepo = App::make(CooperationRepository::class);
        $theme = $this->fakeCooperationData($cooperationFields);
        return $cooperationRepo->create($theme);
    }

    /**
     * Get fake instance of Cooperation
     *
     * @param array $cooperationFields
     * @return Cooperation
     */
    public function fakeCooperation($cooperationFields = [])
    {
        return new Cooperation($this->fakeCooperationData($cooperationFields));
    }

    /**
     * Get fake data of Cooperation
     *
     * @param array $postFields
     * @return array
     */
    public function fakeCooperationData($cooperationFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'channel_id' => $fake->randomDigitNotNull,
            'item_id' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $cooperationFields);
    }
}
